<template>
	<div class="front-padding">
		<div class="widgets bg-white">
			<el-input v-model.trim="searchText" placeholder="输入搜索内容" class="search__input"></el-input>
        	<el-button type="primary">查询</el-button>
        	<div class="btn-group right">
        		<el-button type="primary" @click="add">新增</el-button>
        	</div>
		</div>
		<div class="table bj bg-white">
			<el-scrollbar style="height: 100%;">
				<el-table :data="tableData" border highlight-current-row @selection-change="selectionChange" @row-dblclick="dblClick">
					<el-table-column property="loanCategory" label="借款类别" align="center"></el-table-column>
	                <el-table-column property="levelOneSubjectName" label="一级科目" align="center"></el-table-column>
	                <el-table-column  property="levelTwoSubjectName" label="二级科目" align="center"></el-table-column>
	                <el-table-column property="levelThreeSubjectName" label="三级科目" align="center"></el-table-column>
	                <el-table-column property="levelFourSubjectName" label="四级科目" align="center"></el-table-column>
	                <el-table-column property="remark" label="备注" align="center"></el-table-column>
	                <el-table-column property="state" label="状态" align="center">
	                    <template slot-scope="scope">
	                        <span v-if="scope.row.state == 1" style="color: green;">已启用</span>
	                        <span v-if="scope.row.state == 0" style="color: #f00;">已禁用</span>
	                    </template>
	                </el-table-column>
				</el-table>
			</el-scrollbar>
		</div>
	</div>
</template>
<script>
export default {
	data() {
		return {
			searchText: '',
			tableData: []
		}
	},
	methods: {
		getTableData() {				//获取表格数据
			this.$http.get('loanCategory/findLoanCategory').then(res => {
				if(res.data.code == 20001) {
					if(res.data.data) {
						this.tableData = res.data.data;
					}
				}
			});
		},
		add() {
			this.$util.openLayerIframe({title: '借款类别审批单', width: '800px', height: '500px', url: this.$domain + '/#/basicData/borrowCategory/form'});
		},
		selectionChange(arr) {

        },
        dblClick(row) {			//双击表格行
        	this.$store.commit('borrowOrderStore/updateLoanCategoryName', row['loanCategory']);
        	this.$store.commit('borrowOrderStore/updateLoanCategoryId', row['id']);
        	this.close();
        },
        close() {           //关闭新增弹窗
            let index = parent.layer.getFrameIndex(window.name);    //先得到当前iframe层的索引
            parent.layer.close(index);
        }
	},
	created() {
		this.getTableData();
	}
}
</script>
<style scoped>
	.table {height: calc(100% - 54px);}
	.table .el-table {height: 100% !important;}
</style>